// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   priceAlarm_change_ok.java

package design.config.price_change;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataNumber;

public class priceAlarm_change_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public priceAlarm_change_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		nseer_db_backup1 design_db = new nseer_db_backup1(dbApplication);
		ValidataNumber validata = new ValidataNumber();
		String type_name = request.getParameter("type_name").replaceAll(",", "");
		if (validata.validata(type_name) && Double.parseDouble(type_name) > 0.0D)
		{
			try
			{
				if (design_db.conn((String)dbSession.getAttribute("unit_db_name")))
				{
					String sqll = "select * from design_config_public_char where kind='priceAlarm'";
					ResultSet rs = design_db.executeQuery(sqll);
					if (rs.next())
					{
						String sql2 = (new StringBuilder("update design_config_public_char set type_name='")).append(type_name).append("' where kind='priceAlarm'").toString();
						design_db.executeUpdate(sql2);
					} else
					{
						String sql3 = (new StringBuilder("insert into design_config_public_char(type_name,kind) values('")).append(type_name).append("','priceAlarm')").toString();
						design_db.executeUpdate(sql3);
					}
					design_db.commit();
					design_db.close();
				} else
				{
					response.sendRedirect("error_conn.htm");
				}
			}
			catch (Exception ex)
			{
				ex.printStackTrace();
			}
			response.sendRedirect("design/config/price_change/priceAlarm_change_ok_a.jsp");
		} else
		{
			response.sendRedirect("design/config/price_change/priceAlarm_change_ok_b.jsp");
		}
	}
}
